package com.donleo.security.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.donleo.common.api.CommonResult;
import com.donleo.common.relation.UserLoginRecord;
import com.donleo.security.mapper.UserLoginRecordMapper;
import com.donleo.security.service.UserLoginRecordService;
import com.donleo.security.vo.UserLoginRecordVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 用户登录记录表 服务实现类
 * </p>
 *
 * @author liangd
 * @since 2020-12-21
 */
@Service
public class UserLoginRecordServiceImpl extends ServiceImpl<UserLoginRecordMapper, UserLoginRecord> implements UserLoginRecordService {

    @Autowired
    private UserLoginRecordMapper userLoginRecordMapper;

    @Override
    public List<UserLoginRecord> getAllLoginRecord(UserLoginRecordVo userLoginRecordVo) {
        return userLoginRecordMapper.findAll(userLoginRecordVo);
    }

    @Override
    public long getCount(UserLoginRecordVo userLoginRecordVo) {
        return userLoginRecordMapper.getCount(userLoginRecordVo);
    }

    @Override
    public CommonResult deletes(List<Integer> idsList) {
        int count = userLoginRecordMapper.deleteBatchIds(idsList);
        if (count > 0) {
            return CommonResult.success(count);
        } else {
            return CommonResult.failed();
        }
    }
}
